package com.bw.sofa_module.sofa;

import com.bw.common.mvvm.model.BaseModel;
import com.bw.network_sdk.RetrofitManager;
import com.bw.network_sdk.entity.BaseEntity;
import com.bw.network_sdk.videoentity.VideoEntity;
import com.bw.sofa_module.entity.diss.DissEntity;
import com.bw.sofa_module.entity.likecount.LikeCountEntity;
import com.bw.sofa_module.entity.likestate.LikeStateEntity;

import java.util.Map;

import io.reactivex.Observable;

public class SofaModel extends BaseModel {
    public Observable<BaseEntity> request(Map<String, Object> map) {
        Observable<VideoEntity> entityObservable = RetrofitManager.getInstance()
                .getRetrofit()
                .create(ApiService.class)
                .requestSofa((int) map.get("feedId"),
                        (String) map.get("feedType"),
                        (int) map.get("pageCount"),
                        (int) map.get("userId"));
        return checkNetWork(entityObservable);
    }

    public Observable<BaseEntity> requestLikeState(long itemId, int userId) {
        Observable<LikeStateEntity> likeEntityObservable = RetrofitManager.getInstance()
                .getRetrofit()
                .create(ApiService.class)
                .requestLikeState(itemId, userId);
        return checkNetWork(likeEntityObservable);
    }

    public Observable<BaseEntity> requestLikeCount(long itemId) {
        Observable<LikeCountEntity> likeEntityObservable = RetrofitManager.getInstance()
                .getRetrofit()
                .create(ApiService.class)
                .requestLikeCount(itemId);
        return checkNetWork(likeEntityObservable);
    }

    public Observable<BaseEntity> requestDiss(long itemId, int userId) {
        Observable<DissEntity> likeEntityObservable = RetrofitManager.getInstance()
                .getRetrofit()
                .create(ApiService.class)
                .requestDissState(itemId, userId);
        return checkNetWork(likeEntityObservable);
    }
}
